/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iceberg.adgt.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author David
 */
public class ObserverInterestMap {

	private final Map<ObserverInterest, List<Observer>> map = new HashMap<ObserverInterest, List<Observer>>();

	public final void put(ObserverInterest interest, Observer observer) {
		if (!map.containsKey(interest)) {
			map.put(interest, new ArrayList<Observer>());
		}

		map.get(interest).add(observer);
	}

	public final void notifyObservers(ObserverInterest interest) {
		if (map.size() > 0 && map.get(interest) != null) {
			for (Observer observer : map.get(interest)) {
				observer.notifyChange(interest);
			}
		}
	}
}
